"""
PPT Request Data Model
Defines the structure for PPT generation requests from users.
"""

from pydantic import BaseModel, Field, validator
from typing import Optional
from enum import Enum


class TemplateStyle(str, Enum):
    """Available template styles for PPT generation"""
    PROFESSIONAL = "professional"
    CREATIVE = "creative"
    MINIMAL = "minimal"
    CORPORATE = "corporate"


class PPTRequest(BaseModel):
    """
    Data model for PPT generation requests
    
    Attributes:
        topic: Main topic or theme for the presentation (max 1000 chars)
        requirements: Additional specific requirements (max 2000 chars)
        template_style: Selected template style (default: professional)
        slide_count: Number of slides to generate (5-50, default: 10)
    """
    
    topic: str = Field(
        ...,
        min_length=1,
        max_length=1000,
        description="Main topic or theme for the presentation"
    )
    
    requirements: Optional[str] = Field(
        None,
        max_length=2000,
        description="Additional specific requirements or details"
    )
    
    template_style: TemplateStyle = Field(
        default=TemplateStyle.PROFESSIONAL,
        description="Template style for the presentation"
    )
    
    slide_count: int = Field(
        default=10,
        ge=5,
        le=50,
        description="Number of slides to generate"
    )
    
    @validator('topic')
    def validate_topic(cls, v):
        """Validate topic is not empty after stripping whitespace"""
        if not v or not v.strip():
            raise ValueError('Topic cannot be empty')
        return v.strip()
    
    @validator('requirements')
    def validate_requirements(cls, v):
        """Validate and clean requirements if provided"""
        if v is not None:
            v = v.strip()
            if not v:
                return None
        return v
    
    class Config:
        """Pydantic configuration"""
        use_enum_values = True
        json_encoders = {
            TemplateStyle: lambda v: v.value
        }
        json_schema_extra = {
            "example": {
                "topic": "Introduction to Machine Learning",
                "requirements": "Include practical examples and code snippets. Target audience: beginners",
                "template_style": "professional",
                "slide_count": 15
            }
        }